<?php

namespace App\Admin\Controllers;
use Dcat\Admin\Grid;
use App\Admin\Repositories\User as UserRepository;
use Dcat\Admin\Grid\LazyRenderable;


class User extends LazyRenderable
{
    public function grid(): Grid
    {
        return Grid::make(new UserRepository(), function (Grid $grid) {

            $grid->column('id','ID');
            $grid->column('name','名称');
            $grid->column('avatar','头像')->image();
            $grid->column('sex','性别')->display(function ($status) {
                return $status == 1 ? '男' : ($status == 2 ? '女' : '未知');
            });
            $grid->column('is_invite','是否分销')->display(function ($status) {
                return $status == 1 ? '是' : '否';
            });
            $grid->column('mobile','手机号');
            $grid->paginate(10);
            $grid->disableActions();
            $grid->model()->where('id',  $this->id);
        });
    }
}
